<?php

namespace App\Services;

use App\Models\Agent;
use App\Models\UserProperty;
use App\Models\AgentMoney;
use App\Services\AgentPropertyService;

//帮助公告service
class AgentService
{
    public static function getAgentInfo($id)
    {
        return Agent::find($id);
    }

    public static function getAgentSafeInfo($id){
        if(empty($id)) return null;
        $property = AgentPropertyService::info($id);
        if ($property['idcard']){
            $property['id_card'] = 1;
            $property['id_card_value'] = '****' . substr($property['idcard'], -4);
        }
        if ($property['mobile']){
            $property['mobile'] = 1;
            $property['mobile_value'] = "您验证的手机：**** ". substr($property['mobile'], -4) ." .若已丢失或停用，请立即更换，避免账户被盗";
        }
        if ($property['email']) {
            $property['email'] = 1;
            $email = explode('@', $property['email']);
            if (!empty($email[0]) && !empty($email[1])) {
                $property['email_value'] = "您验证的邮箱：****" . substr($email[0], -2) . '@' . $email[1];
            } else {
                $property['email_value'] = "您验证的邮箱：****" . $property['email'];
            }
        }
        if($money = AgentMoney::where(['agent_id' => $id])->first()){

        }
        return $property;
    }

}
